import http from "@/utils/http/hub";
import { isDev } from "../../utils/env";

/**
 * 获取发票列表
 */
export const getInvoiceList = (
  params,
  config = {
    custom: {
      auth: true,
      loading: false,
    },
  }
) => {
  return http.post({
    url: `/invoice/index`,
    params,
    config,
  });
};

/**
 * 获取发票详情
 */
export const getInvoiceDetail = (
  params,
  config = {
    custom: {
      auth: true,
      loading: false,
    },
  }
) => {
  return http.post({
    url: `/invoice/detail`,
    params,
    config,
  });
};

/**
 * 申请开票提交
 */
export const invoiceSub = (
  params,
  config = {
    custom: {
      auth: true,
      loading: false,
    },
  }
) => {
  return http.post({
    url: `/invoice/invoiceSub`,
    params,
    config,
  });
};

/**
 * 获取发票抬头列表
 */
export const getInvoiceHeaderList = (
  params,
  config = {
    custom: {
      auth: true,
      loading: false,
    },
  }
) => {
  return http.post({
    url: `/invoice/headerList`,
    params,
    config,
  });
  //   if (isDev) {
  //     return new Promise((resolve) => {
  //       resolve({
  //         code: 10000,
  //         data: [
  //           {
  //             invoiceHeaderId: 1, //发票抬头ID
  //             invoiceType: 1,
  //             headerType: 2,
  //             header: "青芒果到家（北京）科技有限公司", //发票抬头
  //             enterpriseAddress: "北京",
  //             taxID: "0200251709200043", //税号
  //             title: "增值税纸质普通发票-企业", //标题
  //           },
  //           {
  //             invoiceHeaderId: 1, //发票抬头ID
  //             invoiceType: 1,
  //             headerType: 2,
  //             header: "青芒果到家（北京）科技有限公司", //发票抬头
  //             enterpriseAddress: "北京",
  //             taxID: "0200251709200043", //税号
  //             title: "增值税纸质普通发票-企业", //标题
  //           },
  //           {
  //             invoiceHeaderId: 1, //发票抬头ID
  //             invoiceType: 1,
  //             headerType: 2,
  //             header: "青芒果到家（北京）科技有限公司", //发票抬头
  //             enterpriseAddress: "北京",
  //             taxID: "0200251709200043", //税号
  //             title: "增值税纸质普通发票-企业", //标题
  //           },
  //         ],
  //       });
  //     });
  //   } else {
  //     return http.post({
  //       url: `/invoice/headerList`,
  //       params,
  //       config,
  //     });
  //   }
};

/**
 * 发票抬头详情
 */
export const headerDetail = (
  params,
  config = {
    custom: {
      auth: true,
      loading: false,
    },
  }
) => {
  return http.post({
    url: `/invoice/headerDetail`,
    params,
    config,
  });
  //   if (isDev) {
  //     return new Promise((resolve) => {
  //       resolve({
  //         code: 10000,
  //         data: {
  //           invoiceHeaderId: 1, //发票抬头ID
  //           userId: 2, //用户ID
  //           invoiceType: 1, //发票类型1=增值税纸质普通发票2=增值税电子普通发票
  //           headerType: 1, //抬头类型1=个人2=企业
  //           header: "青芒果到家（北京）科技有限公司", //发票抬头
  //           taxID: "0200251709200043", //税号
  //           bankDeposit: "中国工商银行", //开户银行
  //           bankAccountNumber: "0922232546445", //银行账号
  //           enterpriseAddress: "北京", //企业地址
  //           enterprisePhone: "13888888888", //企业电话
  //           createdAt: "2025-01-23 13:17:33",
  //           updatedAt: "2025-01-23 13:17:38",
  //           deletedAt: null,
  //         },
  //       });
  //     });
  //   } else {
  //     return http.post({
  //       url: `/invoice/headerDetail`,
  //       params,
  //       config,
  //     });
  //   }
};

/**
 * 发票抬头编辑/创建提交
 */
export const headerSave = (
  params,
  config = {
    custom: {
      auth: true,
      loading: false,
    },
  }
) => {
  return http.post({
    url: `/invoice/headerSave`,
    params,
    config,
  });
};
